<style type="text/css">
	.lig-form .layui-form-label{width:120px;}
  .imglist-none {text-align:center;}
  
  .imgbox {
    background: #fff;
    border: 1px solid transparent;
  }
  .imgbox-content {
    width:170px;
    height: 150px;
  }
  .imgbox-content img {
    max-width: 170px;
    max-height: 150px;
  }
  .imgbox-text {
    text-align:right;
    padding: 5px 0;
  }
  .buttom-btn {
    position: fixed;
    width: 78%;
    bottom: 74px;
    padding: 15px;
    text-align: right;
    background-color: #fff;
    border-top: 1px solid #e2e2e2;
  }
</style>
<div class="layui-fluid" lay-title="客户资料">
	<form class="layui-form lig-form" lay-filter="lig-saveForm">
		<div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
		  <ul class="layui-tab-title">
		    <li class="layui-this">公司信息</li>
		    <li>法人信息</li>
		    <li>图片信息</li>
		  </ul>
		  <div class="layui-tab-content">
		  	<div class="layui-tab-item layui-show customerInfo-customer" style="margin-top:20px;">
		  		
		  	</div>
    		<div class="layui-tab-item customerInfo-customerLegal" style="margin-top:20px;">
    			
    		</div>
    		<div class="layui-tab-item">
          <div class="layui-btn-container nepadmin-pad-t10 nepadmin-pad-l10" style="text-align:right;">
            <button type="button" class="layui-btn layui-btn-lg layui-btn-danger" lay-filter="lig-customerInfo-upload"><i class="layui-icon"></i>上传图片</button>
          </div>
          <div>
            <div class="layui-row layui-col-space30 customerInfo-files">
              <div class="imglist-none">暂无图片</div>
            </div>
          </div>
        </div>
		  </div>
		</div> 
    
	</form>
</div>
<!-- <div class="buttom-btn">
  <button class="layui-btn layui-btn-normal">保存</button>
  <button class="layui-btn layui-btn-primary">取消</button>
</div> -->
<script type="text/html" id="tpl-customer">
	<input type="hidden" name="customerId" value="{{d.id}}" />
    <div class="layui-form-item">
      <div class="layui-inline">
        <label class="layui-form-label">公司名称</label>
        <div class="layui-input-inline">
          <input type="tel" name="name" autocomplete="off" class="layui-input" value="{{d.name || '' }}">
        </div>
      </div>
      <div class="layui-inline">
        <label class="layui-form-label">公司地址</label>
        <div class="layui-input-inline">
          <input type="text" name="address" autocomplete="off" class="layui-input" value="{{d.address || '' }}">
        </div>
      </div>
    </div>
    <div class="layui-form-item">
      <div class="layui-inline">
        <label class="layui-form-label">营业执照号码</label>
        <div class="layui-input-inline">
          <input type="tel" name="certNumber" autocomplete="off" class="layui-input" value="{{d.certNumber || '' }}">
        </div>
      </div>
      <div class="layui-inline">
        <label class="layui-form-label">营业执照发送日期</label>
        <div class="layui-input-inline">
          <input type="text" name="certDate" autocomplete="off" class="layui-input" value='{{layui.lig.toDateString(d.certDate, "yyyy-MM-dd") }}'>
        </div>
      </div>
    </div>
    <div class="layui-form-item">
      <div class="layui-inline">
        <label class="layui-form-label">开户银行</label>
        <div class="layui-input-inline">
          <input type="tel" name="bankName" autocomplete="off" class="layui-input" value="{{d.bankName || '' }}">
        </div>
      </div>
      <div class="layui-inline">
        <label class="layui-form-label">对公账号</label>
        <div class="layui-input-inline">
          <input type="text" name="bankNumber" autocomplete="off" class="layui-input" value="{{d.bankNumber || '' }}">
        </div>
      </div>
    </div>
    <div class="layui-form-item">
      <div class="layui-inline">
        <label class="layui-form-label">纳税等级</label>
        <div class="layui-input-inline">
          <input type="tel" name="taxLevel" autocomplete="off" class="layui-input" value="{{d.taxLevel || '' }}">
        </div>
      </div>
      <div class="layui-inline">
        <label class="layui-form-label">税务登录密码</label>
        <div class="layui-input-inline">
          <input type="text" name="taxPassword" autocomplete="off" class="layui-input" value="{{d.taxPassword || '' }}">
        </div>
      </div>
    </div>
    <div class="layui-form-item">
      <div class="layui-inline">
        <label class="layui-form-label">对公流水年</label>
        <div class="layui-input-inline">
          <input type="tel" name="billWater" autocomplete="off" class="layui-input" value="{{d.billWater || '' }}">
        </div>
      </div>
      <div class="layui-inline">
        <label class="layui-form-label">企业邮箱</label>
        <div class="layui-input-inline">
          <input type="text" name="email" autocomplete="off" class="layui-input" value="{{d.email || '' }}">
        </div>
      </div>
    </div>
    <div class="layui-form-item">
      <div class="layui-inline">
        <label class="layui-form-label">所属银行(4大行)</label>
        <div class="layui-input-inline">
          <input type="tel" name="bank4Name" autocomplete="off" class="layui-input" value="{{d.bank4Name || ''}}">
        </div>
      </div>
      <div class="layui-inline">
        <label class="layui-form-label">4大行常用卡号</label>
        <div class="layui-input-inline">
          <input type="text" name="bank4Number" autocomplete="off" class="layui-input" value="{{d.bank4Number || ''}}">
        </div>
      </div>
    </div>
</script>
<script type="text/html" id="tpl-customerLegal">
	<div class="layui-form-item">
      <div class="layui-inline">
        <label class="layui-form-label">配偶</label>
        <div class="layui-input-inline">
          <input type="tel" name="spouseName" autocomplete="off" class="layui-input" value="{{d.spouseName || ''}}">
        </div>
      </div>
      <div class="layui-inline">
        <label class="layui-form-label">电话号码</label>
        <div class="layui-input-inline">
          <input type="text" name="spouseTel" autocomplete="off" class="layui-input" value="{{d.spouseTel || ''}}">
        </div>
      </div>
    </div>
    <div class="layui-form-item">
      <div class="layui-inline">
        <label class="layui-form-label">身份证号</label>
        <div class="layui-input-inline">
          <input type="tel" name="spouseIdNumber" autocomplete="off" class="layui-input" value="{{d.spouseIdNumber || ''}}">
        </div>
      </div>
      <div class="layui-inline">
        <label class="layui-form-label">是否知晓</label>
        <div class="layui-input-inline">
          {{layui.lig.boolRadioHtml('spouseIsKnow', d.spouseIsKnow)}}
        </div>
      </div>
    </div>
    <div class="layui-form-item">
      <div class="layui-inline">
        <label class="layui-form-label">联系人1</label>
        <div class="layui-input-inline">
          <input type="tel" name="contact1Name" autocomplete="off" class="layui-input" value="{{d.contact1Name || '' }}">
        </div>
      </div>
      <div class="layui-inline">
        <label class="layui-form-label">电话号码</label>
        <div class="layui-input-inline">
          <input type="text" name="contact1Tel" autocomplete="off" class="layui-input" value="{{d.contact1Tel || '' }}">
        </div>
      </div>
      <div class="layui-inline">
        <label class="layui-form-label">关系</label>
        <div class="layui-input-inline">
          <input type="text" name="contact1Relation" autocomplete="off" class="layui-input" value="{{d.contact1Relation || '' }}">
        </div>
      </div>
    </div>
    <div class="layui-form-item">
      <div class="layui-inline">
        <label class="layui-form-label">联系人2</label>
        <div class="layui-input-inline">
          <input type="tel" name="contact2Name" autocomplete="off" class="layui-input" value="{{d.contact2Name || '' }}">
        </div>
      </div>
      <div class="layui-inline">
        <label class="layui-form-label">电话号码</label>
        <div class="layui-input-inline">
          <input type="text" name="contact2Tel" autocomplete="off" class="layui-input" value="{{d.contact2Tel || '' }}">
        </div>
      </div>
      <div class="layui-inline">
        <label class="layui-form-label">关系</label>
        <div class="layui-input-inline">
          <input type="text" name="contact2Relation" autocomplete="off" class="layui-input" value="{{d.contact2Relation || '' }}">
        </div>
      </div>
    </div>
    <div class="layui-form-item">
      <div class="layui-inline">
        <label class="layui-form-label">房产情况</label>
        <div class="layui-input-inline">
          <input type="tel" name="housePayment" autocomplete="off" class="layui-input" value="{{d.housePayment || '' }}">
        </div>
      </div>
      <div class="layui-inline">
        <label class="layui-form-label">是否有房产证</label>
        <div class="layui-input-inline">
          {{layui.lig.boolRadioHtml('houseIsCert', d.houseIsCert)}}
        </div>
      </div>
    </div>
    <div class="layui-form-item">
      <div class="layui-inline">
        <label class="layui-form-label">抵押银行</label>
        <div class="layui-input-inline">
          <input type="tel" name="houseMortgageBank" autocomplete="off" class="layui-input" value="{{d.houseMortgageBank || '' }}">
        </div>
      </div>
      <div class="layui-inline">
        <label class="layui-form-label">到期时间</label>
        <div class="layui-input-inline">
          <input type="text" name="houseMortgageDueDate" autocomplete="off" class="layui-input" value='{{layui.lig.toDateString(d.houseMortgageDueDate, "yyyy-MM-dd") }}'>
        </div>
      </div>
    </div>
    <div class="layui-form-item">
      <div class="layui-inline">
        <label class="layui-form-label">房产地址</label>
        <div class="layui-input-inline">
          <input type="tel" name="houseAddress" autocomplete="off" class="layui-input" value="{{d.houseAddress || '' }}">
        </div>
      </div>
      <div class="layui-inline">
        <label class="layui-form-label">房产价格</label>
        <div class="layui-input-inline">
          <input type="text" name="housePrice" autocomplete="off" class="layui-input" value="{{d.housePrice || '' }}">
        </div>
      </div>
      <div class="layui-inline">
        <label class="layui-form-label">房产性质</label>
        <div class="layui-input-inline">
          <input type="tel" name="houseNature" autocomplete="off" class="layui-input" value="{{d.houseNature || '' }}">
        </div>
      </div>
    </div>
    <div class="layui-form-item">
      <div class="layui-inline">
        <label class="layui-form-label">车辆情况</label>
        <div class="layui-input-inline">
          <input type="tel" name="carPayment" autocomplete="off" class="layui-input" value="{{d.carPayment || '' }}">
        </div>
      </div>
      <div class="layui-inline">
        <label class="layui-form-label">品牌</label>
        <div class="layui-input-inline">
          <input type="text" name="carBrand" autocomplete="off" class="layui-input" value="{{d.carBrand || '' }}">
        </div>
      </div>
    </div>
    <div class="layui-form-item">
      <div class="layui-inline">
        <label class="layui-form-label">行驶里程</label>
        <div class="layui-input-inline">
          <input type="tel" name="carMileage" autocomplete="off" class="layui-input" value="{{d.carMileage || '' }}">
        </div>
      </div>
      <div class="layui-inline">
        <label class="layui-form-label">年限</label>
        <div class="layui-input-inline">
          <input type="text" name="carAgeLimit" autocomplete="off" class="layui-input" value="{{d.carAgeLimit || '' }}">
        </div>
      </div>
      <div class="layui-inline">
        <label class="layui-form-label">裸车</label>
        <div class="layui-input-inline">
          <input type="text" name="carPrice" autocomplete="off" class="layui-input" value="{{d.carPrice || '' }}">
        </div>
      </div>
    </div>
    <div class="layui-form-item">
      <div class="layui-inline">
        <label class="layui-form-label">打卡工资</label>
        <div class="layui-input-inline">
          <input type="tel" name="salary" autocomplete="off" class="layui-input" value="{{d.salary || '' }}">
        </div>
      </div>
      <div class="layui-inline">
        <label class="layui-form-label">连续月份</label>
        <div class="layui-input-inline">
          <input type="text" name="salaryMonthCount" autocomplete="off" class="layui-input" value="{{d.salaryMonthCount || '' }}">
        </div>
      </div>
    </div>
    <div class="layui-form-item">
      <div class="layui-inline">
        <label class="layui-form-label">是否有社保</label>
        <div class="layui-input-inline">
          {{layui.lig.boolRadioHtml('isSocialInsurance', d.isSocialInsurance)}}
        </div>
      </div>
      <div class="layui-inline">
        <label class="layui-form-label">是否有公积金</label>
        <div class="layui-input-inline">
          {{layui.lig.boolRadioHtml('isFund', d.isFund)}}
        </div>
      </div>
      <div class="layui-inline">
        <label class="layui-form-label">是否有商业保险</label>
        <div class="layui-input-inline">
          {{layui.lig.boolRadioHtml('isBusiInsurance', d.isBusiInsurance)}}
        </div>
      </div>
    </div>
    <div class="layui-form-item">
      <div class="layui-inline">
        <label class="layui-form-label">保险公司1</label>
        <div class="layui-input-inline">
          <input type="tel" name="insuranceCompany1" autocomplete="off" class="layui-input" value="{{ d.insuranceCompany1 || '' }}">
        </div>
      </div>
      <div class="layui-inline">
        <label class="layui-form-label">保费</label>
        <div class="layui-input-inline">
          <input type="text" name="insuranceFee1" autocomplete="off" class="layui-input" value="{{d.insuranceFee1 || '' }}">
        </div>
      </div>
    </div>
    <div class="layui-form-item">
      <div class="layui-inline">
        <label class="layui-form-label">保险公司2</label>
        <div class="layui-input-inline">
          <input type="tel" name="insuranceCompany2" autocomplete="off" class="layui-input" value="{{d.insuranceCompany2 || '' }}">
        </div>
      </div>
      <div class="layui-inline">
        <label class="layui-form-label">保费</label>
        <div class="layui-input-inline">
          <input type="text" name="insuranceFee2" autocomplete="off" class="layui-input" value="{{d.insuranceFee2 || '' }}">
        </div>
      </div>
    </div>
</script>
<script type="text/html" id="tpl-customerInfo-files">
  {{#
      layui.each(d, function(i, it) {
  }}
  <div class="layui-col-md2 layui-col-sm4">
    
    <div class="imgbox">
      <input type="hidden" name="fileUrl" value="{{it.fileUrl}}" />
      <input type="hidden" name="fileName" value="{{it.fileName}}" />
      <input type="hidden" name="fileSize" value="{{it.fileSize}}" />
      <input type="hidden" name="fileSuffix" value="{{it.fileSuffix}}" />
      <div class="imgbox-content">
        <a href="javascript:;">
          <img src="{{ layui.lig.reqUrl('/setting/file/output?fileUrl=' + it.fileUrl) }}"/>
        </a>
      </div>
      <div class="imgbox-text">
        <a href="javascript:;" class="imgbox-del">删除</a>
      </div>
    </div>
  </div>
  {{#
      });
  }}
</script>
<script>
    layui.use(['jquery', 'laytpl', 'form', 'layer', 'upload', 'laydate', 'lig'], function ($, laytpl, form, layer, upload, laydate, lig) {


      var prependFile = function(files) {
        $('.imglist-none').remove();

        laytpl($('#tpl-customerInfo-files').html()).render(files, function(html) {
          $('.customerInfo-files').prepend(html);

          $('.customerInfo-files .imgbox-del').unbind('click').click(function() {
            $(this).closest('.layui-col-md2').remove();
          });
        });
      };

    	var initPage = function() {
    		var customerId = parent.customerInfo.customerId;
    		lig.ajaxget({
    			url: 'bu/customer/info/' + customerId,
    			success: function(result) {
            
            var _saveForm = '[lay-filter="lig-saveForm"]';

    				laytpl($('#tpl-customer').html()).render(result.data.customer, function(html) {
    					$('.customerInfo-customer').html(html);

              laydate.render({
                  elem: _saveForm + ' input[name="certDate"]'
              });
              form.render();
    				});

            if (result.data.customerLegal == null) {
              result.data.customerLegal = {};
            }
            laytpl($('#tpl-customerLegal').html()).render(result.data.customerLegal, function(html) {
              $('.customerInfo-customerLegal').html(html);
              laydate.render({
                  elem: _saveForm + ' input[name="houseMortgageDueDate"]'
              });
              form.render();
            });
    				
            if (result.data.files.length > 0) {
              prependFile(result.data.files);
            }
          }
    		});

        upload.render({
          elem: '[lay-filter="lig-customerInfo-upload"]',
          url: lig.reqUrl('/setting/file/upload'),
          done: function(res){
            prependFile(res.data);
          }
        });


      }
        

    	initPage();

    });
</script>